Conversation
type to Long fix: missing package
There was a problem hiding this comment.
Pull request overview
This PR updates the UserInfo data class to improve JSON serialization handling and correct the data type for the updatedAt field. The changes add explicit Gson serialization annotations to all properties and change updatedAt from String? to Long? to properly represent Unix timestamps.
Key changes:
- Added
@SerializedNameannotations to allUserInfoproperties for explicit JSON field mapping - Changed
updatedAttype fromString?toLong?to store Unix timestamps - Updated UI code in both Java and Kotlin demo apps to format the timestamp for display
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| oneloginoidc/src/main/java/com/onelogin/oidc/userInfo/UserInfo.kt | Added Gson annotations and changed updatedAt to Long? |
| appjava/src/main/java/com/onelogin/oidc/appjava/UserInfoFragment.java | Updated to format updatedAt timestamp using SimpleDateFormat |
| app/src/main/java/com/onelogin/oidc/demo/UserInfoFragment.kt | Updated to format updatedAt timestamp using SimpleDateFormat |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| private TextView preferredName; | ||
| private TextView updatedAt; | ||
| private ViewAnimator animator; | ||
| private final SimpleDateFormat format = new SimpleDateFormat("EEE, MMM d, ''yy", Locale.getDefault()); |
There was a problem hiding this comment.
SimpleDateFormat is not thread-safe and should not be stored as an instance field. If this fragment is accessed concurrently or reused, this could cause issues. Consider using ThreadLocal or DateTimeFormatter (API 26+) instead.
| private val preferredName: TextView by lazy { requireView().findViewById<TextView>(R.id.username) } | ||
| private val updatedAt: TextView by lazy { requireView().findViewById<TextView>(R.id.updated_at) } | ||
| private val animator: ViewAnimator by lazy { requireView() as ViewAnimator } | ||
| private val format = SimpleDateFormat("EEE, MMM d, ''yy", Locale.getDefault()) |
There was a problem hiding this comment.
SimpleDateFormat is not thread-safe. While Kotlin's lazy initialization helps, if this fragment is accessed by multiple threads, thread-safety issues could occur. Consider using DateTimeFormatter or create a new SimpleDateFormat instance when needed.
chore: adds gson annotation to UserInfo properties
chore: changes updatedAt type to Long